package yangchen;

import java.util.Random;

public class MinAndMax {
    double min,max;

    public static class GetMinAndMax {
        static double min, man;
        static MinAndMax getResult(double[]A){
            min=A[0];man=A[0];
            for(int x=1;x<10;x++){
                getmin(A[x]);
                getmax(A[x]);
            }
            MinAndMax G=new MinAndMax();
            G.min=min;
            G.max=man;
            return G;
        }
        static void getmin(double i) {
            if(i<min) {
            min=i;
        }

        }
        static void getmax(double x){ if(x>man)man=x; }
    }

    public static void main(String[] args) {
        double[] A=new double[10];
        for(int x=0;x<10;x++) {
            A[x]=new Random().nextDouble()*10;
            System.out.println(A[x]);
        }
        MinAndMax B = new MinAndMax();
        B=GetMinAndMax.getResult(A);
        System.out.println("最大值为"+B.max);
        System.out.println("最小值为"+B.min);
    }
}

